<?php
class Pxy_kc_ctl extends Ctl{
    function __construct(){
    }
    function main(array $xxfget) {
        $this::sessver();
        $type=!empty($_POST['type'])?$_POST['type']:false;
        if(!$type){
            $pid=$xxfget['pid'];
            $pname=xdb::getInstance()->getvar("select pname from peixunban where id=".$pid);
        	$result=xdb::getInstance()->getarray('select * from peixunjiaoshi');
        	$ke=xdb::getInstance()->getarray('select * from peixunkecheng');
        	$pjk=xdb::getInstance()->getarray("select k.kname as kname,k.keshi as keshi,j.tname as tname,jk.id as id,k.ktype as ktype,riqi,kenum from peixun_jk as jk,peixunjiaoshi as j,peixunkecheng as k where jk.pjid=j.id and jk.pkid=k.id and jk.pid=".$pid);
        	$this::show('pxy_kc',compact('result','pname','ke','pjk','pid'));
        }elseif ($type=="add"){
        	$array=array();
        	$array2=array();
        	$kcid = $_POST['kcid'];
        	$jsid = $_POST['jsid'];
        	$pid = $_POST['pid'];
            $array['pjid'] = $jsid;
            $array['pkid'] = $kcid;
            $array['pid'] = $pid;
            $array2['pjid'] = $jsid;
            $array2['pkid'] = $kcid;
            $array2['pid'] = $pid;
        	echo xdb::getInstance()->indb('peixun_jk', $array, $array2);
        }elseif ($type=="del"){
        	$array=array();
        	$id=$_POST['pid'];
        	$array['id']=$id;
        	echo xdb::getInstance()->deldb('peixun_jk', $array);
        }
    }
}